﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DatabaseLibrary;
namespace DatabaseTest
{
   public class Tickets
    {
       TheatreDatabase db = new TheatreDatabase();
       List<Ticket> tickets;
       public string GetTickets(int performanceID)
       {
           tickets = db.GetTicketsForPerformance(performanceID);
           int soldtickets = (from t in tickets where t.IsPaid == true select t).Count();
           int reservedTickets = (from t in tickets where((t.IsPaid==false)&& (t.IsReservation==true))select t).Count();
           int unsoldTickets = (from t in tickets where ((t.IsPaid == false) && (t.IsReservation == false)) select t).Count();
           StringBuilder str = new StringBuilder();
           str.AppendFormat("soldTickets {0}" + Environment.NewLine, soldtickets);
           str.AppendFormat("reservedTickets {0}" + Environment.NewLine, reservedTickets);
           str.AppendFormat("unsoldTickets {0}" + Environment.NewLine, unsoldTickets);
           return str.ToString();
       }
    }
}
